
import java.io.*;
import java.util.*;



public class Properties{
	ArrayList<Tuple> inOut;
	boolean sameElements = true;
	boolean sameSize = true;
	boolean sizeOne = true;
	boolean logic = true;
	boolean removeSucces;

	public Properties(ArrayList<Tuple> inOut){
		this.inOut=inOut;
	}
	
	public boolean getSameSize(){
		return sameSize;
	}
	public boolean getSameElements(){
		return sameElements;
	}
	public boolean getSizeOne(){
		return sizeOne;
	}
	public boolean getLogic(){
		return logic;
	}
	
	//Find properties for all input output pairs, if one pair is false the return is false
	public void findAllProp(){
		int a = inOut.size();
		boolean size;
		boolean elements;
		boolean one;
		boolean log;

		for(int i=0; i<a; i++){
			size = compareSize(inOut.get(i).get(1), inOut.get(i).get(2));
			if(sameSize)
				sameSize=size;

			elements = compareElements(inOut.get(i).get(1), inOut.get(i).get(2));
			if(sameElements)
				sameElements=elements;

			one = checkSizeOne(inOut.get(i).get(1), inOut.get(i).get(2));
			if(sizeOne)
				sizeOne=one;

			log = checkLogic(inOut.get(i).get(1), inOut.get(i).get(2));
			if(logic)
				logic=log;
		}
	}
	private boolean checkLogic(ArrayList<Integer> input, ArrayList<Integer> output){
		for (int i=0; i<input.size(); i++){
			if(input.get(i) != 0 && input.get(i) != 1)
				return false;
		}
		for (int i=0; i<output.size(); i++){
			if(output.get(i) != 0 && output.get(i) != 1)
				return false;
		}
		return true;
	}
	private boolean checkSizeOne(ArrayList<Integer> input, ArrayList<Integer> output){
		if (input.size()==1 && output.size()==1)
			return true;
		else
			return false;
	}

	private boolean compareSize(ArrayList<Integer> input, ArrayList<Integer> output){
		int a = input.size();
            	return (a==output.size());
	}
	
	private boolean compareElements(ArrayList<Integer> input, ArrayList<Integer> output){

		ArrayList<Integer> out = new ArrayList<Integer>();
		for (int n=0; n<output.size(); n++)
			out.add(output.get(n));

		int a = input.size();
		for (int i=0; i<a; i++){	
			if(out.contains(input.get(i))){
				out=rem(input.get(i), out);
				if (!removeSucces){
					return false;
				}
			}
			else{
				return false;
			}
		}
		return true;		
	}

	private ArrayList<Integer> rem(Integer i, ArrayList<Integer> l){
		for (int n=0; n<l.size(); n++){
			if(i.intValue()==l.get(n)){
				l.remove(n);
				removeSucces=true;
				return l;
			}
		}
		removeSucces=false;
		return l;

	}



}
